// pages/scanCode.js
import {getElectronicInfoByCode, getProGoodsByCode} from "../../api/sacnCode"

Page({

    /**
     * 页面的初始数据
     */
    data: {
        active: 0,
        steps: [
            {
                text: '扫电工码',
                inactiveIcon: '/images/inactiveIcon1.png',
                activeIcon: '/images/activeIcon1.png',
            },
            {
                text: '扫外机码',
                inactiveIcon: '/images/inactiveIcon2.png',
                activeIcon: '/images/activeIcon2.png',
            },
            {
                text: '扫内机码',
                inactiveIcon: '/images/inactiveIcon3.png',
                activeIcon: '/images/activeIcon3.png',
            },
            {
                text: '完善信息',
                inactiveIcon: '/images/inactiveIcon4.png',
                activeIcon: '/images/activeIcon4.png',
            },
        ]
    },
    handleScanCode() {
        let _this = this;
        // 电工
        wx.scanCode({
            scanType: ['barCode', 'qrCode', 'datamatrix', 'pdf417'],
            success(res) {
                wx.redirectTo({
                    url: '/pages/scanCodeOld/scanCodeOld?active=' + _this.data.active + '&id=' + res.result,
                })
            },
            fail(err) {
                wx.showModal({
                    title: '提示',
                    content: err,
                    showCancel: false,
                    confirmText: '关闭'
                })
            }
        })
    },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        this.setData({
            active: options.active || 0
        })
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    }
})
